package com.lineage.data.item_etcitem;

import com.lineage.data.executor.ItemExecutor;
import com.lineage.server.model.Instance.L1ItemInstance;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.serverpackets.S_ServerMessage;
import com.lineage.server.serverpackets.ServerBasePacket;
import com.lineage.william.ItemOutburst;

public class ItemFire extends ItemExecutor {
  public static ItemExecutor get() {
    return new ItemFire();
  }
  
  public void execute(int[] data, L1PcInstance pc, L1ItemInstance item) {
    if (item == null)
      return; 
    if (pc == null)
      return; 
    L1ItemInstance AiITEM1 = pc.getInventory().findItemId(92508);
    if (AiITEM1 != null)
      pc.getInventory().removeItem(92508); 
    try {
      Thread.sleep(1L);
    } catch (InterruptedException e) {
      e.printStackTrace();
    } 
    pc.getInventory().storeItem(92508, 1L);
    if (pc.getOutbur()) {
      ItemOutburst.falseOutburst(pc, item);
      pc.setOutbur(false);
      pc.sendPackets((ServerBasePacket)new S_ServerMessage("关闭[爆气]"));
      pc.sendPackets((ServerBasePacket)new S_ServerMessage("目前爆气值:" + pc.getQuburcount()));
    } else {
      if (pc.getQuburcount() == 0) {
        pc.setOutbur(false);
        pc.sendPackets((ServerBasePacket)new S_ServerMessage("\\fU爆气值不足无法开启"));
        return;
      } 
      ItemOutburst.trueOutburst(pc, item);
      pc.setOutbur(true);
      pc.sendPackets((ServerBasePacket)new S_ServerMessage("开启[爆气]"));
      pc.sendPackets((ServerBasePacket)new S_ServerMessage("目前爆气值:" + pc.getQuburcount()));
    } 
  }
}
